<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Mei/jiaList')}">家政列表</a></li>
        <li class="active"><a href="{:url('Mei/jiaAdd')}">添加家政</a></li>
        <li><a href="{:url('Mei/jiaCate')}">添加家政类别</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Mei/businessSave')}">

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>家政名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="name" value="{$res.name|default=''}">
            </div>
        </div>


        <script type="text/javascript">
            $(document).ready(function(){
                $.ajax({
                    type: "POST",
                    url: "{:url('portal/mei/san')}",
                    data: {},
                    dataType:"json",
                    success: function(res){
                        var html = '';
                        var data = res['data'];
                        if(data != ''){
                            $.each(data,function(index,value){
                                html += '<option value="'+data[index]['provinceID']+'">'+data[index]['province']+'</option>';
                            });
                            $("#province").append(html);
                        }
                    }
                });

                $("#province").change(function(){
                    var provinceID = $("#province option:selected").val();
                    $.ajax({
                        type: "POST",
                        url: "{:url('portal/mei/san')}",
                        data: {provinceID:provinceID},
                        dataType:"json",
                        success: function(res){
                            console.log(res);
                            var html = '';
                            $("#city").html('');
                            var data = res['data'];
                            if(data != ''){
                                $.each(data,function(index,value){
                                    html += '<option value="'+data[index]['cityID']+'">'+data[index]['city']+'</option>';
                                });
                                $("#city").append(html);
                            }
                        }
                    });
                });

                $("#city").change(function(){
                    var cityID = $("#city option:selected").val();
                    console.log(cityID);
                    $.ajax({
                        type: "POST",
                        url: "{:url('portal/mei/san')}",
                        data: {cityID:cityID},
                        dataType:"json",
                        success: function(res){
                            console.log(res);
                            var html = '';
                            $("#area").html('');
                            var data = res['data'];
                            if(data != ''){
                                $.each(data,function(index,value){
                                    html += '<option value="'+data[index]['areaID']+'">'+data[index]['area']+'</option>';
                                });
                                $("#area").append(html);
                            }
                        }
                    });
                });
            });
        </script>
        <div class="form-group row">
            <label class="col-sm-2 control-label">所属行政区</label>
            <div class="col-sm-2">
                <select name="province" id="province" class="form-control">
                    <option value="{$res.provinceID|default=''}">{$res.province|default=''}</option>
                </select>
            </div>
            <div class="col-sm-2">
                <select name="city" id="city" class="form-control">
                    <option value="{$res.cityID|default=''}">{$res.city|default=''}</option>
                </select>
            </div>
            <div class="col-sm-2">
                <select name="area" id="area" class="form-control">
                    <option value="{$res.areaID|default=''}">{$res.area|default=''}</option>
                </select>
            </div>
        </div>


        <div class="form-group row">
            <label class="col-sm-2 control-label">所属分类</label>
            <div class="col-sm-3">
                <select name="cate_id" id="cate_id" class="form-control">
                    <option value="0">全部</option>
                    <notempty name="jiacate">
                        <volist name="jiacate" id="jiacate">
                            <option value="{$jiacate.id|default=''}" <notempty name="$res.cate_id">
                            <if condition="$res.cate_id eq $jiacate.id">selected</if>
                        </notempty>>{$jiacate.name|default=''}</option>
                        </volist>
                    </notempty>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>联系方式:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="phone" value="{$res.phone|default=''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>家政账号:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="account" value="{$res.account|default=''}">
            </div>
        </div>

        <input type="hidden" name="type" value="jia">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>密码:</label>
            <div class="col-md-6 col-sm-10">
                <td>
                    <input type="password" class="form-control" name="password" value="{$res.password|default=''}">
                </td>
            </div>
        </div>

        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang("SAVE")}</button>
        </div>
        <input type="hidden" name="id" value="{$res.id|default=''}">
    </form>

</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>